package com.vibration.matlab;

import com.mathworks.toolbox.javabuilder.MWClassID;
import com.mathworks.toolbox.javabuilder.MWException;
import com.mathworks.toolbox.javabuilder.MWNumericArray;
import com.mathworks.toolbox.javabuilder.MWStructArray;
import getT1.GetT1Parameters;

import java.beans.IntrospectionException;

/**
 *得到参数T1
 */
public class GetT1 {

    /**
     * 得到数据T1和TSAM
     */
    public static TransInfo getT1Data(A a, double T1, double TSAM) throws MWException, IntrospectionException {
        GetT1Parameters getT1Parameters=new GetT1Parameters();
        MWNumericArray matArr = new MWNumericArray(a.getL2optimo(), MWClassID.DOUBLE);
        MWStructArray matA = MWStructArray.fromBean(a);
        Object[] response=getT1Parameters.getT1(2,matA,matArr);

        TransInfo transInfo=new TransInfo();

        //拿到参数T1
        MWNumericArray getT1=(MWNumericArray)response[0];
        double[][] getT1Data=(double[][])getT1.toDoubleArray();
        T1=getT1Data[0][0];

        transInfo.setT1(T1);

        //拿到参数T1
        MWNumericArray getTSAM=(MWNumericArray)response[1];
        double[][] getTSAMData=(double[][])getTSAM.toDoubleArray();
        TSAM=getTSAMData[0][0];

        transInfo.setTSAM(TSAM);
        return transInfo;
    }

}
